import { ref,  onMounted,h, getCurrentInstance} from "vue";
import { layer } from '@layui/layui-vue';
import { useUserStore } from '../store/user';   
 
class MyAuth {
    public static   haveUrl(url:string):boolean{
        const userInfoStore = useUserStore();
        const userInfo=userInfoStore.userInfo as any;
        if(userInfo.id=="1000"){
            return true;
        }

        const allpermissions = userInfoStore.permissions as Array<string>;

        var arr=url.split(',');
        for(var i=0;i<arr.length;i++){
            var surl=arr[i];
            if(allpermissions.indexOf(surl)>=0){
                return true;
            }
            var ib=surl.lastIndexOf("/");
            if(ib>0){ 
                surl=surl.slice(0,ib+1)+"*"; 
                if(allpermissions.indexOf(surl)>=0){
                    return true;
                }
            }
        }
        
        return false;
    }
 
}
export default MyAuth